package com.bben.bedcard.controller;

import com.bben.bedcard.mapper.bedcard.TDeptMapper;
import com.bben.bedcard.model.bedcard.TDept;
import com.bben.bedcard.model.bedcard.TDeptExample;
import com.bben.common.BaseController;
import com.bben.common.entity.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/test")
public class TestController extends BaseController {
    @Autowired
    private TDeptMapper tDeptMapper;

    @GetMapping("/add")
    public Result<TDept> add(){
        TDept dept = new TDept();
        dept.setDataId("2");
        dept.setMessageId("2");
        dept.setName("Test2");
        dept.setCreateTime(new Date());
        dept.setCode("0000");
        dept.setRegdeptFlag((byte)0);
        dept.setTatdeptFlag((byte)0);
        dept.setType("");

        Integer rs = tDeptMapper.insertSelective(dept);
        return Result.success("插入成功!",dept);
    }
    @GetMapping("/delete")
    public Result<Integer> delete(){
        TDeptExample deptExample = new TDeptExample();
        deptExample.or().andCodeEqualTo("0000");
        int rs = tDeptMapper.deleteByExample(deptExample);
        return Result.success("删除成功!",rs);
    }
}
